
//
//  CalculatorVC.m
//  tristana
//
//  Created by neobug on 2021/1/13.
//  Copyright © 2021 李康. All rights reserved.
//

#import "CalculatorVC.h"

#import "CalculatorInputCell.h"

#import "CalModel.h"
#import <MJExtension/MJExtension.h>

@interface CalculatorVC () <UITableViewDelegate, UITableViewDataSource>
@property (weak, nonatomic) IBOutlet UITableView *tableView;
@property (nonatomic, strong) NSMutableArray *dataSource;
@end

@implementation CalculatorVC


#pragma mark - Public Method

#pragma mark - Life Cycle

- (void)viewDidLoad {
    [super viewDidLoad];
 
    [self initAllPropertys];
    [self setupUI];
    [self queryData];
}

#pragma mark - Data Query
- (void)queryData {
    
    NSArray *arr = @[@{@"title":@"总价", @"content":@"", @"type":@0, @"lineHeight":@0},
                     @{@"title":@"总价", @"content":@"", @"type":@2, @"lineHeight":@1},
                     @{@"title":@"首付选择", @"content":@"", @"type":@3, @"lineHeight":@5},
                     @{@"title":@"贷款", @"content":@"", @"type":@1, @"lineHeight":@1},
                     @{@"title":@"贷款金额", @"content":@"", @"type":@2, @"lineHeight":@1},
                     @{@"title":@"贷款类别", @"content":@"", @"type":@3, @"lineHeight":@1},
                     @{@"title":@"贷款年数", @"content":@"", @"type":@3, @"lineHeight":@1},
                     @{@"title":@"贷款利率", @"content":@"", @"type":@3, @"lineHeight":@1}];
    
    self.dataSource = [[CalModel mj_objectArrayWithKeyValuesArray:arr] mutableCopy];
    [self.tableView reloadData];
}
#pragma mark - Notification

#pragma mark - UI
- (void)initAllPropertys {
    self.navigationController.navigationBarHidden = NO;
}

- (void)setupUI {
    [self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"cell"];
    [self.tableView registerNib:[UINib nibWithNibName:@"CalculatorInputCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"CalculatorInputCell"];
    self.tableView.tableFooterView = [UIView new];
    
    
}
#pragma mark - Delegate
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.dataSource.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    CalculatorInputCell *cell = (CalculatorInputCell *)[tableView dequeueReusableCellWithIdentifier:@"CalculatorInputCell" forIndexPath:indexPath];
    
    CalModel *model = self.dataSource[indexPath.row];
    cell.model = model;
    
    return cell;
}
#pragma mark - Private Method

#pragma mark - Overwrite Method

#pragma mark - Event Response

#pragma mark - Setter

#pragma mark - Getter
- (NSMutableArray *)dataSource {
    if (!_dataSource) {
        _dataSource = [NSMutableArray array];
    }
    return _dataSource;
}

@end
